/*
 *  Copyright 2001-2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package ar.uba.fi.posgrado.economy.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import ar.uba.fi.posgrado.academy.model.Course;
import ar.uba.fi.posgrado.academy.model.Teacher;
import ar.uba.fi.posgrado.common.model.AbstractDomainObject;

/**
 * Clase que representa honorarios.<br>
 * 
 * @author nicolas.gonzalez
 * @see AbstractDomainObject
 */
@Entity
@Table(name = "HONORARIO")
@SuppressWarnings("serial")
public class Honorary extends AbstractDomainObject {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ID_DOCENTE")
    private Teacher teacher;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ID_CURSO")
    private Course course;
    
    @Column(name = "VIGENCIA_DESDE")
    private Date validityFrom;

    @Column(name = "IMPORTE")
    private Double value;

    @Column(name = "ESTADO")
    private DebtStatus debtStatus; // Cancelled, Paid, Balanced, Active, whatever

    @Column(name = "MOTIVO", length = 255, nullable = true)
    private String reason;
    

    /**
     * 
     */
    public Honorary() {
    }

    /**
     * @param teacher
     * @param course
     * @param validityFrom
     * @param value
     * @param debtStatus
     * @param reason
     */
    public Honorary(Teacher teacher, Course course, Date validityFrom,
            Double value, DebtStatus debtStatus, String reason) {
        this.teacher = teacher;
        this.course = course;
        this.validityFrom = validityFrom;
        this.value = value;
        this.debtStatus = debtStatus;
        this.reason = reason;
    }

    /**
     * @see ar.uba.fi.posgrado.common.model.AbstractDomainObject#getExcludedFields()
     */
    @Override
    public String[] getExcludedFields() {
        return new String[]{"teacher", "course", "validityFrom", "value", "debtStatus", "reason"};
    }

    /**
     * @see DebtStatus#appliesAccountModification()
     */
    public boolean appliesAccountModification() {
        return this.debtStatus.appliesAccountModification();
    }

    
    /**
     * @return the teacher
     */
    public Teacher getTeacher() {
        return this.teacher;
    }

    /**
     * @param teacher the teacher to set
     */
    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }

    /**
     * @return the course
     */
    public Course getCourse() {
        return this.course;
    }

    /**
     * @param course the course to set
     */
    public void setCourse(Course course) {
        this.course = course;
    }

    /**
     * @return the validityFrom
     */
    public Date getValidityFrom() {
        return this.validityFrom;
    }

    /**
     * @param validityFrom the validityFrom to set
     */
    public void setValidityFrom(Date validityFrom) {
        this.validityFrom = validityFrom;
    }

    /**
     * @return the value
     */
    public Double getValue() {
        return this.value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(Double value) {
        this.value = value;
    }

    /**
     * @return the debtStatus
     */
    public DebtStatus getDebtStatus() {
        return this.debtStatus;
    }

    /**
     * @param debtStatus the debtStatus to set
     */
    public void setDebtStatus(DebtStatus debtStatus) {
        this.debtStatus = debtStatus;
    }

    /**
     * @return the reason
     */
    public String getReason() {
        return this.reason;
    }

    /**
     * @param reason the reason to set
     */
    public void setReason(String reason) {
        this.reason = reason;
    }

}
